package com.clayecloud.lib_common.room;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.clayecloud.lib_base.arouter.MyApplication;
import com.clayecloud.lib_common.room.entity.ClientBase;
import com.clayecloud.lib_common.room.entity.ClientToken;
import com.clayecloud.lib_common.room.services.ClientBaseService;
import com.clayecloud.lib_common.room.services.ClientTokenService;
import com.clayecloud.lib_common.room.services.ClientUserService;
import com.clayecloud.lib_common.room.entity.ClientUser;

@Database(entities = {ClientUser.class, ClientToken.class, ClientBase.class}, version = 1)
public abstract class ClientDataBase extends RoomDatabase {

    private static final String DATABASE_NAME = "smartCommunity.db";

    private static ClientDataBase clientDataBaseInstance;

    public static synchronized ClientDataBase getClientDataBaseInstance(){
        if (clientDataBaseInstance == null) {
            clientDataBaseInstance = Room.databaseBuilder(MyApplication.getAppContext(), ClientDataBase.class, DATABASE_NAME).allowMainThreadQueries().build();
        }
        return clientDataBaseInstance;
    }

    public abstract ClientUserService getClientUserService();

    public abstract ClientTokenService getClientTokenService();

    public abstract ClientBaseService getClientBaseService();

}
